# !/usr/bin/env python
# -*- coding: utf-8 -*-
# @File  : 工具创建-创建异步工具.py
# @Author: dongguangwen
# @Date  : 2025-03-23 21:51
import asyncio
from langchain_core.tools import StructuredTool


def multiply(a: int, b: int) -> int:
    """Multiply two numbers."""
    return a * b


calculator = StructuredTool.from_function(func=multiply)


async def main() -> None:
    """Main function."""
    print(calculator.invoke({"a": 2, "b": 3}))
    print(
        await calculator.ainvoke({"a": 2, "b": 5})
    )  # Uses default LangChain async implementation incurs small overhead

asyncio.run(main())

"""
6
10
"""